import axios, { AxiosInstance } from "axios"
// const config = require('../../config')
// const { baseURL } = config[process.env.NODE_ENV]
const service: AxiosInstance = axios.create({
    //   baseURL,
    timeout: 120000,
    headers: {
        "Content-Type": "application/json;charset=UTF-8"
        // 'Accept-Language': getOldLang() || 'tc',
        // 'CMHS-User-Agent': navigator.userAgent
    }
    // withCredentials: true
})

service.interceptors.request.use(
    (config) => {
        // console.log(config)
        config.headers.Authorization = localStorage.getItem("token")
        return config
    },
    (error) => {
        return Promise.reject(error)
    }
)

service.interceptors.response.use(
    (config) => {
        return config
    },
    (error) => {
        // if (error && error?.response && error?.response?.status) {
        //     switch (error?.response?.status) {
        //         case 401:
                    
        //             break
        //         case 500:
                    
        //             break
        //         default:
                    
        //             break
        //     }
        // }
        return Promise.reject(error)
    }
)

export default service
